home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
IRIX Base Documentation 1998 November
/
IRIX 6.5.2 Base Documentation November 1998.img
/
usr
/
share
/
catman
/
u_man
/
cat3
/
malloc_cv.z
/
malloc_cv
Wrap
Text File
|
1998-10-30
|
12KB
|
198 lines
MMMMAAAALLLLLLLLOOOOCCCC____CCCCVVVV((((3333)))) MMMMAAAALLLLLLLLOOOOCCCC____CCCCVVVV((((3333))))
NNNNAAAAMMMMEEEE
malloc, free, realloc, calloc, memalign, valloc, cvmalloc_error -
WorkShop memory allocation library
SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
####iiiinnnncccclllluuuuddddeeee <<<<ssssttttddddlllliiiibbbb....hhhh>>>>
vvvvooooiiiidddd ****mmmmaaaalllllllloooocccc ((((ssssiiiizzzzeeee____tttt ssssiiiizzzzeeee))));;;;
vvvvooooiiiidddd ffffrrrreeeeeeee ((((vvvvooooiiiidddd ****ppppttttrrrr))));;;;
vvvvooooiiiidddd ****rrrreeeeaaaalllllllloooocccc ((((vvvvooooiiiidddd ****ppppttttrrrr,,,, ssssiiiizzzzeeee____tttt ssssiiiizzzzeeee))));;;;
vvvvooooiiiidddd ****ccccaaaalllllllloooocccc ((((ssssiiiizzzzeeee____tttt nnnneeeelllleeeemmmm,,,, ssssiiiizzzzeeee____tttt eeeellllssssiiiizzzzeeee))));;;;
vvvvooooiiiidddd ****mmmmeeeemmmmaaaalllliiiiggggnnnn ((((ssssiiiizzzzeeee____tttt aaaalllliiiiggggnnnnmmmmeeeennnntttt,,,, ssssiiiizzzzeeee____tttt ssssiiiizzzzeeee))));;;;
vvvvooooiiiidddd ****vvvvaaaalllllllloooocccc ((((ssssiiiizzzzeeee____tttt ssssiiiizzzzeeee))));;;;
vvvvooooiiiidddd ccccvvvvmmmmaaaalllllllloooocccc____eeeerrrrrrrroooorrrr ((((cccchhhhaaaarrrr ****mmmmeeeessssssssaaaaggggeeee))));;;;
DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
The WorkShop Performance Tools contain a malloc library, -lmalloc_cv,
which provides tracing and error detection around calls to the various
malloc routines.
The library provides an intercept layer for calls to _m_a_l_l_o_c, _f_r_e_e,
_r_e_a_l_l_o_c, _m_e_m_a_l_i_g_n, and _v_a_l_l_o_c; the intercept allows tracing of all calls
with the WorkShop performance tools.
Calls to _m_a_l_l_o_c, _f_r_e_e, and _r_e_a_l_l_o_c are passed through to whatever memory
allocation library the program is linked with. Calls to _c_a_l_l_o_c are
actually not intercepted, but rely on the underlying calloc to call
_m_a_l_l_o_c to get the space allocated. Calls to _m_e_m_a_l_i_g_n are implemented by
allocating a block large enough to hold the aligned area asked for by the
user, as well as a guard area that holds a flag indicating that the user
block was obtained through memalign, and the address of the larger block.
Calls to _v_a_l_l_o_c are translated into a call to getpagesize, followed by a
memalign call.
The last function, _c_v_m_a_l_l_o_c__e_r_r_o_r is called whenever any error is
detected; a debugger trap may be placed at exit from that routine to
interactively examine malloc errors.
MMMMAAAALLLLLLLLOOOOCCCC TTTTRRRRAAAACCCCIIIINNNNGGGG
The library provides for tracing of all calls to any of the entry points
listed above, as well as any of the errors listed below. The trace is
normally captured using a WorkShop performance experiment. It may be
written in ASCII to stderr by enabling the environment variable
MALLOC_TRACING, although this typically produces a great deal of output.
PPPPaaaaggggeeee 1111
MMMMAAAALLLLLLLLOOOOCCCC____CCCCVVVV((((3333)))) MMMMAAAALLLLLLLLOOOOCCCC____CCCCVVVV((((3333))))
EEEERRRRRRRROOOORRRR DDDDEEEETTTTEEEECCCCTTTTIIIIOOOONNNN
The library will detect some errors under all conditions, and others if
MALLOC_FASTCHK error detection is enabled. All errors pass through the
routine _c_v_m_a_l_l_o_c__e_r_r_o_r and a trap can be placed at the exit from that
routine to catch the problem. Errors are also traced.
The errors that are always detected are:
_m_a_l_l_o_c call failing (returning NULL).
_r_e_a_l_l_o_c call failing (returning NULL).
_r_e_a_l_l_o_c call with an address outside the range of heap addresses
returned by _m_a_l_l_o_c or _m_e_m_a_l_i_g_n.
_m_e_m_a_l_i_g_n call with an improper alignment.
_f_r_e_e call with an address that is improperly aligned.
_f_r_e_e call with an address outside the range of heap addresses
returned by _m_a_l_l_o_c or _m_e_m_a_l_i_g_n.
If MALLOC_FASTCHK is enabled, the library will also detect:
_f_r_e_e or _r_e_a_l_l_o_c calls where the words prior to the user block have
been corrupted.
_f_r_e_e or _r_e_a_l_l_o_c calls where the words following the user block have
been corrupted.
_f_r_e_e or _r_e_a_l_l_o_c calls where the address is that of a block that has
already been freed. This error may not always be detected if the
area around the block is reallocated after it was first freed.
The behavior of the library is governed by various environment variables:
MMMMAAAALLLLLLLLOOOOCCCC____VVVVEEEERRRRBBBBOOOOSSSSEEEE nnnn
(where n is an integer) controls printing of messages from the
library. If n = 0, messages are printed to stderr ony when an error
occurs. If n = 1 (the default), a messages is printed during
initialization, so that the user can tell that the library was
properly included in the application. If n = 2 or greater, detailed
information about all traced events, including the callstack at the
time the error was detected, is printed. This option is not
normally used by the end user, as it can produce a huge vloume of
output.
MMMMAAAALLLLLLLLOOOOCCCC____TTTTRRRRAAAACCCCIIIINNNNGGGG
enables tracing of all calls through the library. Tracing is
normally done in the course of a performance experiment; the
variable need not be set in such cases, as the running of the
experiment will automatically enable it. If the option is enabled
when the program is run independently, and MALLOC_VERBOSE is set to
2 or greater, the trace events and program call stacks will be
written to stderr.
MMMMAAAALLLLLLLLOOOOCCCC____FFFFAAAASSSSTTTTCCCCHHHHKKKK
enables corruption detection for library calls. Corruption
detection is done by allocating a space larger than the requested
area, and putting specific patterns in front of and behind the area
returned to the caller. When _f_r_e_e is called, the patterns are
PPPPaaaaggggeeee 2222
MMMMAAAALLLLLLLLOOOOCCCC____CCCCVVVV((((3333)))) MMMMAAAALLLLLLLLOOOOCCCC____CCCCVVVV((((3333))))
checked, and if the area was overwritten, an error message is
printed using an internal call to the routine _c_v_m_a_l_l_o_c__e_r_r_o_r. Under
the debugger, a trap may be set at exit from this routine to catch
the program at the error.
MMMMAAAALLLLLLLLOOOOCCCC____FFFFUUUULLLLLLLLWWWWAAAARRRRNNNN
enables detection of some calls that are not strictly errors, but
represent sloppy programming, including _f_r_e_e(NULL), _m_a_l_l_o_c(0), and
_r_e_a_l_l_o_c(ptr,0).
MMMMAAAALLLLLLLLOOOOCCCC____MMMMAAAAXXXXMMMMAAAALLLLLLLLOOOOCCCC nnnn
(where n is an integer, in any base) sets a maximum size for any
_m_a_l_l_o_c or _r_e_a_l_l_o_c or _m_e_m_a_l_i_g_n allocation. Any request exceeding
that size will be flagged as an error, and return a NULL pointer.
MMMMAAAALLLLLLLLOOOOCCCC____NNNNOOOO____RRRREEEEUUUUSSSSEEEE
specifies that no area that has been freed will be reused. With
this option enabled, no actual _f_r_e_e calls are really made, and the
process space and swap requirements can grow quite large. If
MALLOC_FASTCHK is not enabled, any space that is freed by a realloc
may or may not get reused; if MALLOC_FASTCHK is enabled, such space
will not be reused.
MMMMAAAALLLLLLLLOOOOCCCC____CCCCLLLLEEEEAAAARRRR____FFFFRRRREEEEEEEE
will clear the data upon any free call. It will only work if
MALLOC_FASTCHK is also enabled.
MMMMAAAALLLLLLLLOOOOCCCC____CCCCLLLLEEEEAAAARRRR____FFFFRRRREEEEEEEE____PPPPAAAATTTTTTTTEEEERRRRNNNN <<<<ppppaaaatttttttteeeerrrrnnnn>>>>
specifies a pattern to clear the data if MALLOC_CLEAR_FREE is
enabled. The default pattern is 0xcafebeef for the 32-bit version,
and 0xcafebeefcafebeef for the 64-bit versions. Only full words
(double words for 64-bits) are cleared to the pattern.
MMMMAAAALLLLLLLLOOOOCCCC____CCCCLLLLEEEEAAAARRRR____MMMMAAAALLLLLLLLOOOOCCCC
will clear the memory area upon each allocation. It also requires
MALLOC_FASTCHK be enabled.
MMMMAAAALLLLLLLLOOOOCCCC____CCCCLLLLEEEEAAAARRRR____MMMMAAAALLLLLLLLOOOOCCCC____PPPPAAAATTTTTTTTEEEERRRRNNNN <<<<ppppaaaatttttttteeeerrrrnnnn>>>>
specifies a pattern to clear the data if MALLOC_CLEAR_MALLOC is
enabled. The default pattern is 0xfacebeef for the 32-bit version,
and 0xfacebeeffacebeef for the 64-bit versions. Only full words
(double words for 64-bits) are cleared to the pattern.
SSSSEEEEEEEE AAAALLLLSSSSOOOO
malloc(3C), malloc(3X), cvspeed(1), cvperf(1).
DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
As ouput from the library routines.
PPPPaaaaggggeeee 3333